#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
@AUTHOR: tyc
@VERSION: 1.0.0
@DESCRIPTION: 爬取八戒网信息
@time: 2021-07-03 11:29:37 
"""
import requests
from lxml import etree
url = 'https://beijing.zbj.com/search/f/?type=new&kw=saas'
# print(requests.get(url).text)
html = etree.HTML(requests.get(url).text)
# 表达式从页面中拷贝下来
divs = html.xpath('/html/body/div[6]/div/div/div[2]/div[5]/div[1]/div')
# print(divs)
for div in divs:
    price = div.xpath('./div/div/a[1]/div[2]/div[1]/span[1]/text()')
    if len(price) == 1:
        price = price[0].strip("¥")
    else:
        continue
    num = div.xpath('./div/div/a[1]/div[2]/div[1]/span[2]/text()')[0]
    title = div.xpath('./div/div/a[1]/div[2]/div[2]/p/text()')[0]
    work_name = div.xpath('./div/div/a[2]/div[1]/p/text()')[0].strip()
    address = div.xpath('./div/div/a[2]/div[1]/div[1]/span/text()')[0]
    we_chat = div.xpath('./div/div/a[2]/div[3]/div/object/a/@href')
    print(price, num, title, work_name, address, we_chat)


